import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { BullModule } from '@nestjs/bull';
import { VideoProcessor } from './services/VideoProcessor';
import { entities } from './entities';
import { VideoService } from './services/video.service';

@Module({
    imports: [
        BullModule.forRoot({
            redis: {
                host: process.env.REDIS_HOST || 'localhost',
                port: process.env.REDIS_PORT ? +process.env.REDIS_PORT : 6379,
            },
        }),
        BullModule.registerQueue({
            name: 'video',
        }),
        TypeOrmModule.forRoot({
            type: 'postgres',
            host: process.env.DATABASE_HOST || 'localhost',
            port: process.env.DATABASE_PORT ? +process.env.DATABASE_PORT : 5432,
            username: 'postgres',
            password: process.env.DATABASE_PASSWORD || 'postgres',
            database: 'postgres',
            entities,
            synchronize: true,
        }),
        TypeOrmModule.forFeature(entities),
    ],
    controllers: [AppController],
    providers: [
        AppService,
        VideoProcessor,
        VideoService,
    ],
})
export class AppModule {
}
